#ifndef WAVEWIDGET_H
#define WAVEWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QProcess>
#include <QLabel>

#include "sys_data_struct.h"
#include "BRE_EEG_dataStruct.h"
#include "TreeDirectoryInterface.h"

#include "qcustomplot.h"

namespace Ui {
class WaveWidget;
}

class WaveWidget : public QWidget
{
    Q_OBJECT

    friend class TreeDirectoryInterface;

public:
    explicit WaveWidget(QWidget *parent = nullptr);
    ~WaveWidget();

    int plotInit();
    void begin_plot();


public slots:
    // 添加放大器的数据
    // void add_eegData(std::shared_ptr<QVector<EEG_VOLTAGE>> data);
    void receive_eegData(const std::vector<EEG_VOLTAGE>& data);

    
    // 添加随机数函数
    void add_randomData();
    // void add_eegData(const std::vector<EEG_VOLTAGE>& data);
    void add_eegData();
    void timeToRePlot();
private slots:
    void on_btm_clear_clicked(bool checked);
    void on_btm_pause_clicked(bool checked);
    void on_btm_collect_clicked(bool checked);
    void on_btm_record_clicked(bool checked);
    void on_btm_load_clicked(bool checked);




signals:
    void widgetClose(uint8_t winID);

protected:
    // void keyPressEvent(QKeyEvent *event) override;
    // void mouseDoubleClickEvent(QMouseEvent *event) override;
    void closeEvent(QCloseEvent *event);


private:
    Ui::WaveWidget *ui;

    QCustomPlot *customPlot;
    QTimer rePlotTimer;
    QTimer dataTimer_wave;
    bool  m_start_wave;
    std::vector<EEG_VOLTAGE> eegData_voltage;


    // 一条线上同时显示的点数
    int pointNumPerLine;

    // 曲线条数
    int  m_countGraph;

    // 刷新数据的位置
    long long plot_index;


};

#endif // waveWidget_H